<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%--
  Created by IntelliJ IDEA.
  User: lzy
  Date: 2018/9/6
  Time: 22:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Details</title>
</head>
<body>
<h4>Product Details by struts2</h4>
product name:${productName}
<br/><br/>
product desc:<s:property value="[1].productDesc"/>
<br/><br/>
product price:${productPrice}
<br/><br/>
product price:<s:property value="[0].productPrice"/>
<br/><br/>
product price:<s:property value="productPrice"/>
<hr/>
productName: ${sessionScope.product.productName}
<br/><br/>
test name: ${requestScope.test.productName}
<hr/>
productName: <s:property value="#session.product.productName"/>
<br/><br/>
test name: <s:property value="#request.test.productName"/>
<hr/>
<%--使用OGNL调用public类的public类型的静态字段和静态方法--%>
<s:property value="@java.lang.Math@PI"/>
<br/>
<s:property value="@java.lang.Math@cos(0)"/>
<br/>
<%--调用对象栈的方法为一个属性赋值--%>
<s:property value="setProductName('atguigu')"/>
<s:property value="productName"/>
<br/>
<%--调用数组对象的属性--%>
<%
    String[] names = new String[]{"aa", "bb", "cc", "dd"};
    request.setAttribute("names", names);
%>
names length: <s:property value="#attr.names.length"/>
<br>
names[2]: <s:property value="#attr.names[2]"/>
<h6>Map</h6>
<%
    Map<String, String> letters = new HashMap<>();
    letters.put("a", "A");
    letters.put("b", "B");
    letters.put("c", "C");
    request.setAttribute("letters", letters);
%>
<s:property value="#attr.letters.size"/>
<br/>
a:<s:property value="#attr.letters[\"a\"]"/>
<s:debug></s:debug>

</body>
</html>
